<?php
 require_once('tpl/header.php');
 //幻灯片视频显示
 $sql_slides = "select * from videos 
 where istop=1 and  pic is not null 
 order by vid desc limit 0,3";
 $res_sledes = mysqli_query($link,$sql_slides);
 $vs_slides = mysqli_fetch_all($res_sledes,MYSQLI_ASSOC);
 //构建多维数组，根据$vtypes
 $allvideos = array();
 foreach($vtypes as $vt){
	 $sql = "select * from videos where pic is not null and tid="
			.$vt['tid']
			." order by vid desc limit 0,8";
	 //echo $sql;
	 $res = mysqli_query($link,$sql);
	 $vs = mysqli_fetch_all($res,MYSQLI_ASSOC);
	 $vss = array("tid"=>$vt['tid'],
				  "typename"=>$vt['typename'],
				  "videos"=>$vs);
	 $allvideos[]=$vss;
 }
 //var_dump($allvideos);exit;
?>
<div class="container">


<!--幻灯片开始-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
		
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
       <?php
		foreach($vs_slides as $index=>$slide){
	   ?>
        <div class="item <?php if($index==0) echo "active"; ?>">
			
            <img src="uploads/poster/<?php echo $slide['pic'];?>" class="img-responsive" alt="Apple iPhone 5S">

            <div class="carousel-caption">
                <h3><?php echo $slide['videoname'];  ?></h3>

            </div>
        </div>
		<?php
		}
		?>
		</div>
    </div>

    <!-- Controls -->
    <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
</div>
<!--幻灯片结束-->






    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-9">


            <div class="row text-center">
			
			    <?php
					foreach($allvideos as $onetype){
				
				?>
			
                <div class="col-xs-12 col-lg-12 mlist">
                    <h2><?php echo $onetype['typename'];?></h2>
                    <ul class="list-inline row text-center">
                        <?php
						foreach($onetype['videos'] as $video){
						?>
						<li class="col-xs-4 col-sm-3 col-lg-2">
                            <img src="uploads/poster/<?php echo $video['pic'];?>" class="responsive img-thumbnail"/>

                            <p><a href="show.php?vid=<?php echo $video['vid'];?>"><?php echo $video['videoname'];?></a>
                            </p>
                        </li>
                        <?php
						}
						?>

                    </ul>
                    <p><a class="btn btn-default" href="list.php?tid=<?php echo $onetype['tid']; ?>" role="button">更多 &raquo;</a></p>
                </div>
                <!--/.col-xs-6.col-lg-4-->
				<?php
					}
				?>
				
				

            </div>
            <!--/row-->
        </div>
        <!--/.col-xs-12.col-sm-9-->

        <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar">
            <div class="list-group text-center">
                <h2 style="color:white;" >排行</h2>
                <ul class="list-inline row text-center">
                    <li class="col-xs-12 col-lg-6">
                        <img src="assets/images/img1.jpg" class="responsive img-thumbnail"/>

                        <p><a href="show.html">视频标题</a>
                        </p>
                    </li>
                    <li class="col-xs-12 col-lg-6">
                        <img src="assets/images/img1.jpg" class="responsive img-thumbnail"/>

                        <p><a href="show.html">视频标题</a>
                        </p>
                    </li>

                </ul>
            </div>

        </div>
        <!--/.sidebar-offcanvas-->
    </div>
    <!--/row-->

   

</div>
<!--/.container-->
 <?php
	require_once('tpl/footer.php');
 ?>